# -*- mode: python ; coding: utf-8 -*-

import sys
import os

# 获取项目根目录 - 修正版本
project_root = os.path.dirname(os.path.abspath('app.py'))

# 分析阶段
a = Analysis(
    ['app.py'],
    pathex=[project_root],
    binaries=[],
    datas=[
        # 添加所有需要的资源文件和目录
        (os.path.join(project_root, 'config'), 'config'),
        (os.path.join(project_root, 'ocr'), 'ocr'),
        (os.path.join(project_root, 'gui'), 'gui'),
        (os.path.join(project_root, 'utils'), 'utils'),
    ],
    hiddenimports=[
        # 显式包含所有可能需要的模块
        'tkinter',
        'tkinter.ttk',
        'tkinter.messagebox',
        'PIL',
        'PIL.Image',
        'PIL.ImageGrab',
        'PIL.ImageTk',
        'dashscope',
        'dashscope.api_entities',
        'dashscope.aigc',
        'dashscope.common',
        'dashscope.utils',
        'dashscope.multimodal',
        'dashscope.generation',
    ],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=None,
    noarchive=False,
)

# PYZ打包
pyz = PYZ(a.pure, a.zipped_data, cipher=None)

# EXE配置
exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='屏幕OCR工具',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,  # 关键：设置为False以避免控制台窗口
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
